#ifndef _SERIAL_PORT_H
#define _SERIAL_PORT_H
#include <stdio.h>  
#include <stdlib.h> 
#include <string.h>  
#include <sys/types.h>   
#include <sys/stat.h>  
#include <fcntl.h>  
#include <unistd.h>  
#include <termios.h>  
#include <errno.h> 

#include "user_buffer.h"

typedef struct serial_cfg_t{
    int baudrate;
    int databits;
    int stopbits;
    int parity;
    int hardflow;
} serial_cfg_t;


void serial_process_options(int argc, char * argv[], serial_cfg_t *conf, char *devname);
void serial_conf_print(serial_cfg_t conf);
int serial_port_init(int *fd, const char *devname,const  serial_cfg_t *conf, RingBuffer *recv_data);

int serial_read(int fd, RingBuffer *recv_buffer, int recv_len);
int serial_write(int fd,  const uint8_t *buf, int len);

int serial_close(int fd);



#endif // _SERIAL_PORT_H